home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / CRT.SWG / 0001_XY Cursor Position in ASM.pas next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  46 lines

  1. {
  2. > If anyone is interested in the BAsm GotoXY/WhereX/WhereY routines
  3. > I'll be happy to post them.   They use standard BIOS routines, and
  4.  
  5. I simply followed an Interrupt listing I had to create these Functions.
  6.  
  7. Note the DEC commands in GotoXY, and the INC command in Each WHERE* Function.
  8. These are there to make the Procedures/Functions Compatible With the TP Crt
  9. routines, which are 1-based.  (ie: 1,1 in TP.Crt is upper left hand corner).
  10. The BIOS routines need to be given 0,0 For the same coordinates.   If you don't
  11. want to remain Compatible With Turbo's GotoXY and WHERE* Functions, delete them
  12. out and keep your code Zero-based For X/Y screen coords.
  13. }
  14.  
  15. Procedure GotoXY(X,Y : Byte); Assembler; Asm
  16.   MOV DH, Y    { DH = Row (Y) }
  17.   MOV DL, X    { DL = Column (X) }
  18.   DEC DH       { Adjust For Zero-based Bios routines }
  19.   DEC DL       { Turbo Crt.GotoXY is 1-based }
  20.   MOV BH,0     { Display page 0 }
  21.   MOV AH,2     { Call For SET CURSOR POSITION }
  22.   INT 10h
  23. end;
  24.  
  25. Function  WhereX : Byte;  Assembler;
  26. Asm
  27.   MOV     AH,3      {Ask For current cursor position}
  28.   MOV     BH,0      { On page 0 }
  29.   INT     10h       { Return inFormation in DX }
  30.   INC     DL        { Bios Assumes Zero-based. Crt.WhereX Uses 1 based }
  31.   MOV     AL, DL    { Return X position in AL For use in Byte Result }
  32. end;
  33.  
  34. Function WhereY : Byte; Assembler;
  35. Asm
  36.   MOV     AH,3     {Ask For current cursor position}
  37.   MOV     BH,0     { On page 0 }
  38.   INT     10h      { Return inFormation in DX }
  39.   INC     DH       { Bios Assumes Zero-based. Crt.WhereY Uses 1 based }
  40.   MOV     AL, DH   { Return Y position in AL For use in Byte Result }
  41. end;
  42.  
  43. {
  44. Note that the WhereX and WhereY Function call the exact same Bios function.
  45. }
  46.